<template>
  <div class="settings-container">
    <!-- 页面头部 -->
    <div class="settings-header">
      <div class="header-content">
        <div class="header-left">
          <div class="page-title">
            <el-icon class="title-icon"><Setting /></el-icon>
            <span>系统设置</span>
          </div>
          <div class="page-desc">配置和管理系统的各项参数设置</div>
        </div>
      </div>
    </div>

    <div class="settings-content">
      <el-row :gutter="24">
        <!-- 左侧设置分类 -->
        <el-col :span="6">
          <div class="settings-sidebar">
            <div class="sidebar-title">设置分类</div>
            
            <!-- 设置统计卡片 -->
            <div class="settings-stats">
              <div class="stat-item">
                <div class="stat-icon">⚙️</div>
                <div class="stat-info">
                  <div class="stat-number">1</div>
                  <div class="stat-label">配置模块</div>
                </div>
              </div>
              <div class="stat-item">
                <div class="stat-icon">✅</div>
                <div class="stat-info">
                  <div class="stat-number">{{ getConfiguredCount() }}</div>
                  <div class="stat-label">已配置</div>
                </div>
              </div>
            </div>
            
            <el-menu
              :default-active="activeTab"
              class="settings-menu"
              @select="handleTabChange"
            >
              <el-menu-item index="basic" class="menu-item-basic">
                <el-icon><Operation /></el-icon>
                <span>基础设置</span>
                <div class="menu-item-badge">基础</div>
              </el-menu-item>
            </el-menu>
          </div>
        </el-col>

        <!-- 右侧设置内容 -->
        <el-col :span="18">
          <div class="settings-main">
            <!-- 基础设置 -->
            <div v-show="activeTab === 'basic'" class="settings-panel">
              <div class="panel-header">
                <h3>基础设置</h3>
                <p>配置系统的基本信息和参数</p>
              </div>
              
              <el-form :model="basicSettings" label-width="120px" class="settings-form">
                <el-form-item label="系统名称">
                  <el-input v-model="basicSettings.systemName" placeholder="请输入系统名称" />
                </el-form-item>
                
                <el-form-item label="系统版本">
                  <el-input v-model="basicSettings.version" placeholder="请输入版本号" />
                </el-form-item>
                
                <el-form-item label="系统描述">
                  <el-input
                    v-model="basicSettings.description"
                    type="textarea"
                    :rows="3"
                    placeholder="请输入系统描述"
                  />
                </el-form-item>
                
                <el-form-item label="公司名称">
                  <el-input v-model="basicSettings.companyName" placeholder="请输入公司名称" />
                </el-form-item>
                
                <el-form-item label="联系邮箱">
                  <el-input v-model="basicSettings.contactEmail" placeholder="请输入联系邮箱" />
                </el-form-item>
                
              </el-form>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useUserStore } from '@/stores/user'
import {
  Setting,
  Check,
  RefreshLeft,
  Operation,
  Lock,
  Message,
  FolderOpened,
  Monitor,
  Download,
  Upload,
  Connection,
  Plus,
  Delete
} from '@element-plus/icons-vue'

// 用户状态管理
const userStore = useUserStore()

// 响应式数据
const activeTab = ref('basic')
const saving = ref(false)
const backupLoading = ref(false)

// 基础设置
const basicSettings = reactive({
  systemName: 'SG3L 管理系统',
  version: '1.0.0',
  description: '基于 Vue3 + Element Plus 的现代化管理系统',
  companyName: '示例公司',
  contactEmail: 'admin@example.com',
  timezone: 'Asia/Shanghai',
  language: 'zh-CN'
})

// 安全设置
const securitySettings = reactive({
  passwordPolicy: ['requireNumber', 'requireUppercase'],
  minPasswordLength: 8,
  maxLoginAttempts: 5,
  sessionTimeout: 120,
  twoFactorAuth: false,
  ipWhitelistEnabled: false
})

// 邮件设置
const emailSettings = reactive({
  smtpHost: '',
  smtpPort: 587,
  encryption: 'tls',
  fromEmail: '',
  fromName: '',
  username: '',
  password: ''
})

// 存储设置
const storageSettings = reactive({
  type: 'local',
  maxFileSize: 10,
  allowedTypes: ['image', 'document'],
  cacheExpire: 24
})

// 外观设置
const appearanceSettings = reactive({
  primaryColor: '#667eea',
  logo: '',
  layout: 'sidebar',
  fixedHeader: true,
  pageAnimation: true
})

// 备份历史
const backupHistory = ref([
  {
    id: 1,
    name: 'system_backup_20240120.zip',
    size: '2.5 MB',
    createTime: '2024-01-20 14:30:00'
  },
  {
    id: 2,
    name: 'system_backup_20240115.zip',
    size: '2.3 MB',
    createTime: '2024-01-15 10:15:00'
  }
])

// 切换设置标签
const handleTabChange = (key) => {
  activeTab.value = key
}

// 保存所有设置
const saveAllSettings = async () => {
  try {
    saving.value = true
    
    // 模拟保存API调用
    await new Promise(resolve => setTimeout(resolve, 1500))
    
    // 保存到本地存储
    localStorage.setItem('systemSettings', JSON.stringify({
      basic: basicSettings,
      security: securitySettings,
      email: emailSettings,
      storage: storageSettings,
      appearance: appearanceSettings
    }))
    
    ElMessage.success('设置保存成功')
  } catch (error) {
    ElMessage.error('设置保存失败')
  } finally {
    saving.value = false
  }
}

// 恢复默认设置
const resetToDefault = async () => {
  try {
    await ElMessageBox.confirm('确定要恢复默认设置吗？此操作将覆盖所有当前设置。', '确认恢复', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
    
    // 重置所有设置为默认值
    Object.assign(basicSettings, {
      systemName: 'AdminSG3L 管理系统',
      version: '1.0.0',
      description: '基于 Vue3 + Element Plus 的现代化管理系统',
      companyName: '示例公司',
      contactEmail: 'admin@example.com',
      timezone: 'Asia/Shanghai',
      language: 'zh-CN'
    })
    
    Object.assign(securitySettings, {
      passwordPolicy: ['requireNumber', 'requireUppercase'],
      minPasswordLength: 8,
      maxLoginAttempts: 5,
      sessionTimeout: 120,
      twoFactorAuth: false,
      ipWhitelistEnabled: false
    })
    
    ElMessage.success('已恢复默认设置')
  } catch (error) {
    // 用户取消操作
  }
}

// 测试邮件连接
const testEmailConnection = async () => {
  try {
    // 模拟测试连接
    await new Promise(resolve => setTimeout(resolve, 2000))
    ElMessage.success('邮件服务器连接测试成功')
  } catch (error) {
    ElMessage.error('邮件服务器连接测试失败')
  }
}

// Logo上传前检查
const beforeLogoUpload = (file) => {
  const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
  const isLt2M = file.size / 1024 / 1024 < 2
  
  if (!isJPG) {
    ElMessage.error('Logo只能是 JPG/PNG 格式!')
    return false
  }
  if (!isLt2M) {
    ElMessage.error('Logo大小不能超过 2MB!')
    return false
  }
  return true
}

// 创建备份
const createBackup = async () => {
  try {
    backupLoading.value = true
    
    // 模拟创建备份
    await new Promise(resolve => setTimeout(resolve, 3000))
    
    const now = new Date()
    const fileName = `system_backup_${now.getFullYear()}${(now.getMonth() + 1).toString().padStart(2, '0')}${now.getDate().toString().padStart(2, '0')}.zip`
    
    backupHistory.value.unshift({
      id: Date.now(),
      name: fileName,
      size: '2.8 MB',
      createTime: now.toLocaleString()
    })
    
    ElMessage.success('备份创建成功')
  } catch (error) {
    ElMessage.error('备份创建失败')
  } finally {
    backupLoading.value = false
  }
}

// 备份文件上传前检查
const beforeBackupUpload = (file) => {
  const isZip = file.type === 'application/zip'
  const isLt10M = file.size / 1024 / 1024 < 10
  
  if (!isZip) {
    ElMessage.error('只能上传 ZIP 格式的备份文件!')
    return false
  }
  if (!isLt10M) {
    ElMessage.error('备份文件大小不能超过 10MB!')
    return false
  }
  
  // 模拟还原过程
  ElMessage.success('备份文件上传成功，正在还原...')
  setTimeout(() => {
    ElMessage.success('系统还原完成')
  }, 2000)
  
  return false // 阻止自动上传
}

// 下载备份
const downloadBackup = (backup) => {
  ElMessage.info(`正在下载 ${backup.name}...`)
  // 实际项目中这里会触发文件下载
}

// 还原备份
const restoreBackup = async (backup) => {
  try {
    await ElMessageBox.confirm(`确定要还原备份 "${backup.name}" 吗？此操作将覆盖当前系统设置。`, '确认还原', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
    
    ElMessage.success(`正在还原备份 ${backup.name}...`)
    // 实际项目中这里会执行还原逻辑
  } catch (error) {
    // 用户取消操作
  }
}

// 删除备份
const deleteBackup = async (backup) => {
  try {
    await ElMessageBox.confirm(`确定要删除备份 "${backup.name}" 吗？此操作不可恢复。`, '确认删除', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
    
    const index = backupHistory.value.findIndex(item => item.id === backup.id)
    if (index > -1) {
      backupHistory.value.splice(index, 1)
      ElMessage.success('备份删除成功')
    }
  } catch (error) {
    // 用户取消操作
  }
}

const getConfiguredCount = () => {
  // 计算已配置的模块数量
  let count = 0
  if (basicSettings.systemName) count++
  if (securitySettings.passwordPolicy.length > 0) count++
  if (emailSettings.smtpHost) count++
  if (storageSettings.type) count++
  if (appearanceSettings.primaryColor) count++
  return count
}

// 组件挂载时加载设置
onMounted(() => {
  const savedSettings = localStorage.getItem('systemSettings')
  if (savedSettings) {
    try {
      const settings = JSON.parse(savedSettings)
      Object.assign(basicSettings, settings.basic || {})
      Object.assign(securitySettings, settings.security || {})
      Object.assign(emailSettings, settings.email || {})
      Object.assign(storageSettings, settings.storage || {})
      Object.assign(appearanceSettings, settings.appearance || {})
    } catch (error) {
      console.error('加载设置失败:', error)
    }
  }
})
</script>

<style scoped>
.settings-container {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px 0;
}

.settings-header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: none;
  border-radius: 20px;
  margin: 0 32px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.settings-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 40px;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

.header-left {
  flex: 1;
}

.page-title {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  from { filter: drop-shadow(0 0 5px rgba(102, 126, 234, 0.3)); }
  to { filter: drop-shadow(0 0 15px rgba(102, 126, 234, 0.6)); }
}

.title-icon {
  color: #667eea;
  font-size: 32px;
  animation: iconSpin 3s linear infinite;
}

@keyframes iconSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.page-desc {
  color: #64748b;
  font-size: 16px;
  font-weight: 500;
  opacity: 0.8;
}

.header-actions {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header-actions .el-button {
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  border: none;
  position: relative;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-actions .el-button--primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.header-actions .el-button--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.header-actions .el-button:not(.el-button--primary) {
  background: rgba(255, 255, 255, 0.8);
  color: #667eea;
  border: 2px solid transparent;
  backdrop-filter: blur(10px);
}

.header-actions .el-button:not(.el-button--primary):hover {
  background: rgba(255, 255, 255, 1);
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.settings-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px 32px;
}

.settings-sidebar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(15px);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  min-height: 700px;
  display: flex;
  flex-direction: column;
}

.settings-sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
  z-index: 0;
}

.settings-sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  z-index: 1;
}

.sidebar-title {
  padding: 28px 28px 24px;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border-bottom: 2px solid rgba(102, 126, 234, 0.15);
  position: relative;
  z-index: 1;
  text-align: center;
  letter-spacing: 1px;
}

.sidebar-title::before {
  content: '⚙️';
  margin-right: 12px;
  font-size: 18px;
  animation: rotate 4s linear infinite;
}

.sidebar-title::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  border-radius: 2px;
}

.settings-menu {
  border: none;
  background: transparent;
  position: relative;
  z-index: 1;
  flex: 1;
  padding-bottom: 16px;
}

.settings-menu :deep(.el-menu-item) {
  height: 64px;
  line-height: 64px;
  padding: 0 24px;
  margin: 12px 20px;
  border-radius: 18px;
  color: #64748b;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-weight: 600;
  font-size: 15px;
}

.settings-menu :deep(.el-menu-item::before) {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  transition: left 0.6s ease;
}

.settings-menu :deep(.el-menu-item:hover::before) {
  left: 100%;
}

.settings-menu :deep(.el-menu-item:hover) {
  background: rgba(255, 255, 255, 0.9);
  color: #667eea;
  transform: translateX(6px) translateY(-2px);
  box-shadow: 0 8px 32px rgba(102, 126, 234, 0.25);
  border-color: rgba(102, 126, 234, 0.3);
}

.settings-menu :deep(.el-menu-item.is-active) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  transform: translateX(6px) translateY(-2px);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.5);
  border-color: transparent;
  position: relative;
}

.settings-menu :deep(.el-menu-item.is-active::after) {
  content: '';
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px 0 0 4px;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
}

.settings-menu :deep(.el-menu-item.is-active::before) {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  pointer-events: none;
}

.settings-menu :deep(.el-menu-item .el-icon) {
  margin-right: 16px;
  font-size: 20px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 8px;
  padding: 2px;
}

.settings-menu :deep(.el-menu-item:hover .el-icon) {
  transform: scale(1.1) rotate(5deg);
  background: rgba(102, 126, 234, 0.2);
  color: #667eea;
}

.settings-menu :deep(.el-menu-item.is-active .el-icon) {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  transform: scale(1.1);
}

.settings-menu :deep(.menu-item-badge) {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(102, 126, 234, 0.2);
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.settings-menu :deep(.el-menu-item:hover .menu-item-badge) {
  background: rgba(102, 126, 234, 0.2);
  color: #667eea;
  transform: translateY(-50%) scale(1.05);
  border-color: rgba(102, 126, 234, 0.4);
}

.settings-menu :deep(.el-menu-item.is-active .menu-item-badge) {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-50%) scale(1.1);
}

/* 不同类型菜单项的特殊样式 */
.settings-menu :deep(.menu-item-basic.is-active) {
  background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}

.settings-menu :deep(.menu-item-security.is-active) {
  background: linear-gradient(135deg, #ef4444 0%, #f87171 100%);
}

.settings-menu :deep(.menu-item-email.is-active) {
  background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
}

.settings-menu :deep(.menu-item-storage.is-active) {
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
}

.settings-menu :deep(.menu-item-appearance.is-active) {
  background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
}

.settings-menu :deep(.menu-item-backup.is-active) {
  background: linear-gradient(135deg, #06b6d4 0%, #67e8f9 100%);
}

/* 设置统计卡片样式 */
.settings-stats {
  margin: 20px 16px;
  display: flex;
  gap: 12px;
}

.stat-item {
  flex: 1;
  background: rgba(255, 255, 255, 0.8);
  padding: 16px 12px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  text-align: center;
  transition: all 0.3s ease;
}

.stat-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
  background: rgba(255, 255, 255, 0.9);
}

.stat-icon {
  font-size: 16px;
  margin-bottom: 6px;
}

.stat-number {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

/* 侧边栏快捷操作样式 */
.sidebar-actions {
  margin: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-actions .action-btn {
  width: 100%;
  height: 40px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  position: relative;
  overflow: hidden;
}

.sidebar-actions .el-button--primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.sidebar-actions .el-button--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

.sidebar-actions .el-button:not(.el-button--primary) {
  background: rgba(255, 255, 255, 0.8);
  color: #667eea;
  border: 2px solid rgba(102, 126, 234, 0.2);
  backdrop-filter: blur(10px);
}

.sidebar-actions .el-button:not(.el-button--primary):hover {
  background: rgba(255, 255, 255, 1);
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.settings-main {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(15px);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  min-height: 700px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}

.settings-main::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.02) 0%, rgba(118, 75, 162, 0.02) 100%);
  z-index: 0;
}

.settings-panel {
  padding: 40px;
  position: relative;
  z-index: 1;
}

.panel-header {
  margin-bottom: 40px;
  border-bottom: 2px solid transparent;
  background: linear-gradient(white, white) padding-box,
              linear-gradient(135deg, #667eea 0%, #764ba2 100%) border-box;
  border-radius: 16px;
  padding: 24px 32px;
  position: relative;
  background-color: rgba(102, 126, 234, 0.03);
}

.panel-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  border-radius: 16px 16px 0 0;
}

.panel-header h3 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-header h3::before {
  content: '⚙️';
  font-size: 20px;
  animation: rotate 3s linear infinite;
}

@keyframes rotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.panel-header p {
  color: #64748b;
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.settings-form {
  max-width: 700px;
  background: rgba(255, 255, 255, 0.7);
  padding: 32px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
}

.settings-form :deep(.el-form-item) {
  margin-bottom: 28px;
  transition: all 0.3s ease;
}

.settings-form :deep(.el-form-item:hover) {
  transform: translateY(-2px);
}

.settings-form :deep(.el-form-item__label) {
  color: #1e293b;
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
}

.settings-form :deep(.el-input__wrapper) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 2px solid transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(255, 255, 255, 0.9);
}

.settings-form :deep(.el-input__wrapper:hover) {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.3);
}

.settings-form :deep(.el-input__wrapper.is-focus) {
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
  border-color: #667eea;
}

.settings-form :deep(.el-textarea__inner) {
  border-radius: 12px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.9);
}

.settings-form :deep(.el-textarea__inner:hover) {
  border-color: rgba(102, 126, 234, 0.3);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.settings-form :deep(.el-textarea__inner:focus) {
  border-color: #667eea;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.settings-form :deep(.el-select .el-input__wrapper) {
  background: rgba(255, 255, 255, 0.9);
}

.settings-form :deep(.el-button) {
  border-radius: 12px;
  font-weight: 600;
  padding: 12px 24px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-form :deep(.el-button--primary) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.settings-form :deep(.el-button--primary:hover) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

.form-tip {
  color: #64748b;
  font-size: 13px;
  margin-left: 12px;
  font-weight: 500;
  padding: 4px 8px;
  background: rgba(102, 126, 234, 0.1);
  border-radius: 6px;
  border-left: 3px solid #667eea;
}

.color-picker-group {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: rgba(102, 126, 234, 0.05);
  border-radius: 12px;
  border: 2px solid rgba(102, 126, 234, 0.1);
  transition: all 0.3s ease;
}

.color-picker-group:hover {
  background: rgba(102, 126, 234, 0.1);
  border-color: rgba(102, 126, 234, 0.2);
  transform: translateY(-2px);
}

.color-label {
  color: #1e293b;
  font-size: 16px;
  font-weight: 600;
}

.logo-uploader {
  border: 3px dashed rgba(102, 126, 234, 0.3);
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(102, 126, 234, 0.02);
}

.logo-uploader:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.logo-uploader-icon {
  font-size: 32px;
  color: #667eea;
  width: 140px;
  height: 140px;
  text-align: center;
  line-height: 140px;
  transition: all 0.3s ease;
}

.logo-uploader:hover .logo-uploader-icon {
  transform: scale(1.2) rotate(5deg);
  color: #764ba2;
}

.logo-preview {
  width: 140px;
  height: 140px;
  display: block;
  object-fit: cover;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.logo-uploader:hover .logo-preview {
  transform: scale(1.05);
}

.backup-section {
  max-width: 900px;
}

.backup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 16px 0;
}

.backup-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.2);
}

.backup-info h4 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 8px 0;
}

.backup-info p {
  color: #64748b;
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.backup-history {
  margin-top: 40px;
  background: rgba(255, 255, 255, 0.7);
  padding: 32px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
}

.backup-history h4 {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.backup-history h4::before {
  content: '📋';
  font-size: 18px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .header-content,
  .settings-content {
    padding-left: 20px;
    padding-right: 20px;
  }
  
  .settings-header {
    margin: 0 20px 20px;
  }
}

@media (max-width: 768px) {
  .settings-container {
    padding: 10px 0;
  }
  
  .settings-header {
    margin: 0 10px 15px;
    border-radius: 16px;
  }
  
  .header-content {
    flex-direction: column;
    gap: 20px;
    text-align: center;
    padding: 24px 20px;
  }
  
  .header-actions {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .settings-content {
    padding: 0 10px 20px;
  }
  
  .settings-content .el-col {
    margin-bottom: 20px;
  }
  
  .settings-panel {
    padding: 24px 20px;
  }
  
  .settings-form {
    padding: 24px 20px;
  }
  
  .backup-item {
    flex-direction: column;
    gap: 20px;
    text-align: center;
    padding: 24px 20px;
  }
  
  .page-title {
    font-size: 24px;
  }
  
  .title-icon {
    font-size: 28px;
  }
  
  /* 移动端侧边栏样式 */
  .settings-sidebar {
    min-height: auto;
  }
  
  .settings-stats {
    flex-direction: column;
    gap: 8px;
  }
  
  .sidebar-actions {
    flex-direction: row;
    gap: 8px;
  }
  
  .sidebar-actions .action-btn {
    height: 36px;
    font-size: 12px;
  }
  
  .settings-menu :deep(.el-menu-item) {
    height: 52px;
    line-height: 52px;
    margin: 8px 12px;
    font-size: 14px;
  }
  
  .settings-menu :deep(.menu-item-badge) {
    font-size: 10px;
    padding: 2px 6px;
    right: 12px;
  }
}

/* 美化滚动条 */
:deep(.el-scrollbar__wrap) {
  padding-right: 17px;
  margin-right: -17px;
}

:deep(.el-scrollbar__bar) {
  opacity: 0.6;
  border-radius: 4px;
}

:deep(.el-scrollbar__thumb) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 4px;
  transition: all 0.3s ease;
}

:deep(.el-scrollbar__thumb:hover) {
  background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
}

/* 表格样式优化 */
:deep(.el-table) {
  border-radius: 16px;
  overflow: hidden;
  border: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

:deep(.el-table th) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-weight: 700;
  border: none;
  padding: 16px 12px;
}

:deep(.el-table td) {
  border: none;
  padding: 16px 12px;
  background: rgba(255, 255, 255, 0.9);
}

:deep(.el-table tr:hover td) {
  background: rgba(102, 126, 234, 0.05);
}

:deep(.el-table .el-button) {
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

:deep(.el-table .el-button:hover) {
  transform: translateY(-1px);
}

/* 开关样式 */
:deep(.el-switch) {
  --el-switch-on-color: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --el-switch-off-color: #e2e8f0;
  border-radius: 20px;
}

:deep(.el-switch__core) {
  border-radius: 20px;
  background: var(--el-switch-off-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

:deep(.el-switch.is-checked .el-switch__core) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* 复选框组样式 */
:deep(.el-checkbox-group) {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(102, 126, 234, 0.03);
  padding: 20px;
  border-radius: 12px;
  border: 2px solid rgba(102, 126, 234, 0.1);
}

:deep(.el-checkbox) {
  margin-right: 0;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

:deep(.el-checkbox:hover) {
  background: rgba(102, 126, 234, 0.05);
  transform: translateX(4px);
}

:deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
}

/* 单选框组样式 */
:deep(.el-radio-group) {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(102, 126, 234, 0.03);
  padding: 20px;
  border-radius: 12px;
  border: 2px solid rgba(102, 126, 234, 0.1);
}

:deep(.el-radio) {
  margin-right: 0;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

:deep(.el-radio:hover) {
  background: rgba(102, 126, 234, 0.05);
  transform: translateX(4px);
}

:deep(.el-radio__input.is-checked .el-radio__inner) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: #667eea;
}

/* 输入数字组件样式 */
:deep(.el-input-number) {
  border-radius: 12px;
}

:deep(.el-input-number .el-input__wrapper) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

:deep(.el-input-number:hover .el-input__wrapper) {
  border-color: rgba(102, 126, 234, 0.3);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

:deep(.el-input-number.is-focus .el-input__wrapper) {
  border-color: #667eea;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

/* 按钮组样式 */
:deep(.el-button-group) {
  display: flex;
  gap: 12px;
}

:deep(.el-button-group .el-button) {
  border-radius: 12px;
  border: none;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 上传组件样式 */
:deep(.el-upload) {
  border: none;
  border-radius: 12px;
}

:deep(.el-upload .el-button) {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.3s ease;
}

:deep(.el-upload .el-button:hover) {
  background: rgba(102, 126, 234, 0.2);
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

/* 颜色选择器样式 */
:deep(.el-color-picker) {
  --el-color-picker-alpha-bg-a: 0.3;
  border-radius: 12px;
  transition: all 0.3s ease;
}

:deep(.el-color-picker:hover) {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* 分割线样式 */
:deep(.el-divider) {
  border-color: rgba(102, 126, 234, 0.2);
  margin: 32px 0;
  position: relative;
}

:deep(.el-divider::before) {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.3), transparent);
  transform: translateY(-50%);
}

/* 加载状态样式 */
:deep(.el-loading-mask) {
  background: rgba(102, 126, 234, 0.1);
  backdrop-filter: blur(10px);
}

:deep(.el-loading-spinner .circular) {
  stroke: #667eea;
  stroke-width: 3;
}

/* 消息框样式优化 */
:deep(.el-message-box) {
  border-radius: 20px;
  border: none;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(15px);
}

:deep(.el-message-box__title) {
  color: #1e293b;
  font-weight: 700;
}

:deep(.el-message-box__content) {
  color: #64748b;
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-panel {
  animation: fadeInUp 0.6s ease-out;
}

.settings-form :deep(.el-form-item) {
  animation: fadeInUp 0.6s ease-out;
  animation-fill-mode: both;
}

.settings-form :deep(.el-form-item:nth-child(1)) { animation-delay: 0.1s; }
.settings-form :deep(.el-form-item:nth-child(2)) { animation-delay: 0.2s; }
.settings-form :deep(.el-form-item:nth-child(3)) { animation-delay: 0.3s; }
.settings-form :deep(.el-form-item:nth-child(4)) { animation-delay: 0.4s; }
.settings-form :deep(.el-form-item:nth-child(5)) { animation-delay: 0.5s; }

/* 悬浮效果 */
.settings-sidebar,
.settings-main {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-sidebar:hover,
.settings-main:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
}
</style>
